<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#registerBtn").click(function(){
			if($("#content").val()==""){
				alert("내용을 입력하세요");
			}else{
				location.href="writeGuestBook.do?content="+$("#content").val();
			}
		});
		$("span[id^='deleteBtn']").click(function(){
			if($(this).parent().children(":first").val()==$("#loginId").val()){
				if(confirm("삭제하시겠습니까?")){
					location.href="deleteGuestBook.do?no="+$(this).parent().parent().children().find("[id^='listNo']").val();
				}
			}else if($("#userGrade").val()=="Manager"||$("#userGrade").val()=="SubManager"){
				if(confirm("삭제하시겠습니까?")){
					location.href="deleteGuestBook.do?no="+$(this).parent().parent().children().find("[id^='listNo']").val();
				}
			}else{
				alert("자신의 글만 삭제 가능합니다");
			}
		});
	});
</script>
<style type="text/css">
.CSSTableGenerator {
	margin:0px;padding:0px;
	width:50%;
	border:1px solid #000000;
	
	-moz-border-radius-bottomleft:6px;
	-webkit-border-bottom-left-radius:6px;
	border-bottom-left-radius:6px;
	
	-moz-border-radius-bottomright:6px;
	-webkit-border-bottom-right-radius:6px;
	border-bottom-right-radius:6px;
	
	-moz-border-radius-topright:6px;
	-webkit-border-top-right-radius:6px;
	border-top-right-radius:6px;
	
	-moz-border-radius-topleft:6px;
	-webkit-border-top-left-radius:6px;
	border-top-left-radius:6px;
}.CSSTableGenerator table{
    border-collapse: collapse;
        border-spacing: 0;
	width:100%;
	height:100%;
	margin:0px;padding:0px;
}.CSSTableGenerator tr:last-child td:last-child {
	-moz-border-radius-bottomright:6px;
	-webkit-border-bottom-right-radius:6px;
	border-bottom-right-radius:6px;
}
.CSSTableGenerator table tr:first-child td:first-child {
	-moz-border-radius-topleft:6px;
	-webkit-border-top-left-radius:6px;
	border-top-left-radius:6px;
}
.CSSTableGenerator table tr:first-child td:last-child {
	-moz-border-radius-topright:6px;
	-webkit-border-top-right-radius:6px;
	border-top-right-radius:6px;
}.CSSTableGenerator tr:last-child td:first-child{
	-moz-border-radius-bottomleft:6px;
	-webkit-border-bottom-left-radius:6px;
	border-bottom-left-radius:6px;
}.CSSTableGenerator tr:hover td{
	
}
.CSSTableGenerator tr:nth-child(odd){ background-color:#e5e5e5; }
.CSSTableGenerator tr:nth-child(even){ background-color:#ffffff; }
.CSSTableGenerator td{
	vertical-align:middle;	
	border:1px solid #000000;
	border-width:0px 1px 1px 0px;
	text-align:left;
	padding:4px;
	font-size:14px;
	font-family:Arial;
	font-weight:bold;
	color:#000000;
}
.CSSTableGenerator tr:last-child td{
	border-width:0px 1px 0px 0px;
}
.CSSTableGenerator tr td:last-child{
	border-width:0px 0px 1px 0px;
}
.CSSTableGenerator tr:last-child td:last-child{
	border-width:0px 0px 0px 0px;
}
.CSSTableGenerator tr:first-child td{
		background:-o-linear-gradient(bottom, #cccccc 5%, #b2b2b2 100%);	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #cccccc), color-stop(1, #b2b2b2) );
	background:-moz-linear-gradient( center top, #cccccc 5%, #b2b2b2 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#cccccc", endColorstr="#b2b2b2");	background: -o-linear-gradient(top,#cccccc,b2b2b2);

	background-color:#cccccc;
	border:0px solid #000000;
	text-align:center;
	border-width:0px 0px 1px 1px;
	font-size:12px;
	font-family:Arial;
	font-weight:bold;
	color:#000000;
}
.CSSTableGenerator tr:first-child:hover td{
	background:-o-linear-gradient(bottom, #cccccc 5%, #b2b2b2 100%);	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #cccccc), color-stop(1, #b2b2b2) );
	background:-moz-linear-gradient( center top, #cccccc 5%, #b2b2b2 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#cccccc", endColorstr="#b2b2b2");	background: -o-linear-gradient(top,#cccccc,b2b2b2);

	background-color:#cccccc;
}
.CSSTableGenerator tr:first-child td:first-child{
	border-width:0px 0px 1px 0px;
}
.CSSTableGenerator tr:first-child td:last-child{
	border-width:0px 0px 1px 1px;
}
.css_guestbook_bt {
	font-size:13px;
	font-family:Arial;
	font-weight:bold;
	-moz-border-radius:9px;
	-webkit-border-radius:9px;
	border-radius:9px;
	border:1px solid #0;
	padding:3px 6px;
	text-decoration:none;
	background:-webkit-gradient( linear, left top, left bottom, color-stop(5%, #ededed), color-stop(100%, #dfdfdf) );
	background:-moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% );
	background:-ms-linear-gradient( top, #ededed 5%, #dfdfdf 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
	background-color:#ededed;
	color:#777777;
	display:inline-block;
	text-shadow:0px 0px 0px #ffffff;
 	-webkit-box-shadow:inset 1px 0px 0px 0px #ffffff;
 	-moz-box-shadow:inset 1px 0px 0px 0px #ffffff;
 	box-shadow:inset 1px 0px 0px 0px #ffffff;
}.css_header_bt:hover {
	background:-webkit-gradient( linear, left top, left bottom, color-stop(5%, #dfdfdf), color-stop(100%, #ededed) );
	background:-moz-linear-gradient( center top, #dfdfdf 5%, #ededed 100% );
	background:-ms-linear-gradient( top, #dfdfdf 5%, #ededed 100% );
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#ededed');
	background-color:#dfdfdf;
}.css_header_bt:active {
	position:relative;
	top:1px;
}
</style>
</head>
<body>
<c:set var="pb" value="requestScope.slist.pb"></c:set>
<center>
<img src="${initParam.root}/img/guestbook.jpg">
<input type="hidden" value="${sessionScope.vo.id}" id="loginId">
<input type="hidden" value="${sessionScope.vo.grade}" id="userGrade">
<c:choose>
	<c:when test="${sessionScope.vo!=null }">
		<table class="CSSTableGenerator">
			<tr>
				<td colspan="2">${sessionScope.vo.name }(${sessionScope.vo.nick })</td>
			</tr>
			<tr>
				<td><textarea rows="1" cols="52" id="content"></textarea> </td>
				<td><input type="button" value="메모하기" id="registerBtn" class="css_guestbook_bt"></td>
			</tr>
		</table>
		<br>
	</c:when>
</c:choose>
<table class="CSSTableGenerator">
<tbody>
<c:forEach items="${requestScope.slist.subboardList }" var="slist">
<tr>
	<td colspan="2">
		<table>
			<tr>
				<td width="300">${slist.memberVO.nick}</td><td>${slist.writeDate}</td>
			</tr>
		</table>
	</td>
</tr>
<tr>
	<td width="400"><input type="hidden" value="${slist.no}" id="listNo">${slist.content}</td><td align="right"><input type="hidden" value="${slist.memberVO.id}" id="id"><span id="deleteBtn"><input type="button" value="삭제" class="css_guestbook_bt"></span></td>
</tr>
</c:forEach>
</tbody>
</table>

<c:set var="pb" value="${requestScope.slist.pb}"></c:set>
<ul id="css_page">
<c:if test="${pb.previousPageGroup}">
	<li><a href="guestbook_board.do?pageNo=${pb.startPageOfPageGroup-1 }">
	◀</a></li>
</c:if>
 <c:forEach var="i" begin="${pb.startPageOfPageGroup }"  end="${pb.endPageOfPageGroup }">
 <c:choose>
 	<c:when test="${pb.nowPage!=i }">
 	<li><a href="guestbook_board.do?pageNo=${i }">${i }</a></li>
 	</c:when>
 	<c:otherwise>
 		<li> ${i}</li>
 	</c:otherwise>
 </c:choose>
 </c:forEach>
 <c:if test="${pb.nextPageGroup }">
	  <li><a href="guestbook_board.do?pageNo=${pb.endPageOfPageGroup+1}">▶</a></li>
</c:if>
</ul>
</center>
</body>
</html>